import {
  HTTP
} from '../utils/http'

class OrderModel extends HTTP {

  /// 订单列表
  list(current = 1, size = 10, type = 0) {
    return this.request({
      url: 'order/getOrderList',
      data: {
        current: current,
        size: size,
        type: type
      }
    })
  }
  isConfirmOrderList(current, size) {
    return this.request({
      url: 'order/agentOrder',
      data: {
        current: current,
        size: size,
      }
    })
  }

  /// 订单详情
  detail(orderId) {
    return this.request({
      url: 'order/orderDetail',
      data: {
        orderId: orderId || 0
      }
    })
  }

  /// 地址信息
  address() {
    return this.request({
      url: 'order/myGatherAddressList',
    })
  }
  /// 单个商品
  promptlyChooseOk(quantity, goodsId, goodsSkuId) {
    return this.request({
      url: 'order/promptlyChooseOk',
      data: {
        quantity: quantity,
        goodsId: goodsId,
        goodsSkuId: goodsSkuId
      }
    })
  }
  /// 选择完毕参数
  chooseOk(commodityIds) {
    return this.request({
      url: 'order/chooseOk',
      data: {
        commodityIds: commodityIds
      }
    })
  }

  /// 优惠券列表
  conponList(goodsIds, satisfyPrice) {
    return this.request({
      url: 'order/myConponList',
      data: {
        goodsIds: goodsIds,
        satisfyPrice: satisfyPrice
      }
    })
  }

  /// 商品详情生成订单
  order(addressId, goodsId, quantity, goodsSkuId, couponId, isDeduction, agentType) {
    return this.request({
      url: 'order/promptlyCreateOrder',
      data: {
        addressId: addressId, //地址id
        goodsId: goodsId, //商品id
        quantity: quantity, //商品数量
        goodsSkuId: goodsSkuId, //skuid
        couponId: couponId || 0, //优惠券id
        isDeduction: isDeduction || 0, //是否使用了花花 0否 1是
        agentType: agentType
      }
    })
  }

  /// 购物车生成订单
  create(addressId, commodityIds, couponId, isDeduction) {
    return this.request({
      url: 'order/createOrder',
      data: {
        addressId: addressId, //地址id
        commodityIds: commodityIds, //购物车id
        couponId: couponId || 0, //优惠券id
        isDeduction: isDeduction || 0, //是否使用了花花 0否 1是
      }
    })
  }

  /// vip 订单
  vip(addressId, goodsIds) {
    return this.request({
      url: 'order/createVipOrder',
      data: {
        addressId: addressId, //地址id
        goodsIds: goodsIds, //商品id
      }
    })
  }

  /// 支付订单collegeCourseBuyRecord/buy
  course(courseId, payType) {
    return this.request({
      url: 'collegeCourseBuyRecord/buy',
      data: {
        courseId: courseId, //地址id
        payType: payType || 2, //商品id
      }
    })
  }


  /// 取消订单
  cancel(orderId) {
    return this.request({
      url: 'order/cancelOrder',
      data: {
        orderId: orderId
      }
    })
  }

  /// 支付订单
  pay(orderId) {
    return this.request({
      url: 'pay/v2/appletsUnificationOrder',
      data: {
        type: 0,
        orderId: orderId,
        payType: 2
      }
    })
  }
  customMadeGoodsList(current, size) {
    return this.request({
      url: 'customMadeGoods/list',
      data: {
        current: current || 1,
        size: size || 100,
      }
    })
  }
  orderEntry(name, phone, address, store, customMadeGoodsId) {
    return this.request({
      url: 'customMadeOrder/orderEntry',
      data: {
        name: name,
        phone: phone,
        address: address,
        store: store,
        customMadeGoodsId: customMadeGoodsId,
      }
    })
  }
  manage() {
    return this.request({
      url: 'customMadeOrder/manage',
    })
  }
  orderCenter(current, size) {
    return this.request({
      url: 'customMadeOrder/orderCenter',
      data: {
        current: current || 1,
        size: size || 100,
      }
    })
  }
  cycle(current, size) {
    return this.request({
      url: 'customMadeOrder/cycle',
      data: {
        current: current || 1,
        size: size || 100,
      }
    })
  }
  bindOrder(code) {
    return this.request({
      url: 'customMadeOrder/bindOrder',
      data: {
        code: code,
      }
    })
  }
  customMadeGoodsList(current, size) {
    return this.request({
      url: 'customMadeGoods/list',
      data: {
        current: current || 1,
        size: size || 100,
      }
    })
  }
  saveOrUpdate(data) {
    return this.request({
      url: 'customMadeGoods/saveOrUpdate',
      data: data
    })
  }
  customMadeGoodsDel(id) {
    return this.request({
      url: 'customMadeGoods/del',
      data: {
        id: id
      }
    })
  }
  //定制列表
  customMadeOrderList(current,size,status) {
    return this.request({
      url: 'customMadeOrder/list',
      data: {
        current: current || 1,
        size: size || 100,
        status:status
      }
    })
  }
  //定制详情
  customMadeOrderDetail(orderId) {
    return this.request({
      url: 'customMadeOrder/detail',
      data: {
        orderId: orderId
      }
    })
  }
  //历史日记
  customMadeDiaryList(current,size,orderId) {
    return this.request({
      url: 'customMadeDiary/list',
      data: {
        current: current || 1,
        size: size || 100,
        orderId:orderId
      }
    })
  }
  //更新日记
  customMadeDiarySave(customMadeOrderId,explains,imgs,status) {
    return this.request({
      url: 'customMadeDiary/save',
      data: {
        customMadeOrderId: customMadeOrderId,
        explains: explains,
        imgs:imgs,
        status:status,
      }
    })
  }
  //日记详情
  customMadeDiaryDetail(id) {
    return this.request({
      url: 'customMadeDiary/detail',
      data: {
        id: id
      }
    })
  }
}


export {
  OrderModel
}